package view.drawable;

import model.Noeud;

import java.awt.*;

/**
 * Created with IntelliJ IDEA.
 * User: Thomas
 * Date: 08/02/14
 * Time: 11:35
 * To change this template use File | Settings | File Templates.
 */
public class NoeudDrawable extends FormDrawable {

    private Noeud noeud;

    /**
     * @param pos   the coordinate of the center this form
     * @param dim   the dimension of this form
     */
    public NoeudDrawable(Point pos, Dimension dim, Noeud noeud) {
        super(Color.WHITE, pos, dim);
        this.setNoeud(noeud);
    }

    public Noeud getNoeud() {
        return noeud;
    }

    public void setNoeud(Noeud noeud) {
        this.noeud = noeud;
    }

    @Override
    public void setPosition(Point p) {
        super.setPosition(p);
    }

    @Override
    public void draw(Graphics g) {
        if (this.isDrawing()) {
            return;
        }

        Color c = Color.WHITE;
        if (this.isSelected()) {
            g.setColor(Color.RED);
        } else {
            g.setColor(c);
        }
        g.fillRect(rect.x,rect.y,rect.width,rect.height);
        g.drawString(this.getNoeud().getName(), rect.x, rect.y);
        g.setColor(c);
    }
}
